#include "ThreadSafeQueue.h"
namespace re
{
	namespace real{
template<class T>
void ThreadSafeQueue<T>::push(T& data)
{
	boost::mutex::scoped_lock lock(m_mutex);
	m_queue.push(data);
	lock.unlock();
	m_condition_var.notify_one();
}
template<class T>
bool ThreadSafeQueue<T>::try_pop(T& data)
{
	boost::mutex::scoped_lock lock(m_mutex);
	if(m_queue.empty())
	{
		return false;
	}
	data = m_queue.front;
	m_queue.pop();
	return true;
}
template<class T>
bool ThreadSafeQueue<T>::wait_pop(T& data)
{
	boost::mutex::scoped_lock lock(m_mutex);
	while(m_queue.empty())
	{
		m_condition_var.wait(lock);
	}
	data = m_queue.front;
	m_queue.pop();
	return true;
}
template<class T>
bool ThreadSafeQueue<T>::is_empty()
{
	boost::mutex::scoped_lock lock(m_mutex);
	return m_queue.empty();
}


}
}